﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Validity
{
  public class ValidationResult
  {
    private readonly IEnumerable<RuleViolation> _ruleViolations;
    private readonly String _description;
    private readonly String _propertyName;
    private readonly Boolean _isValid;

    public Boolean IsValid { get { return _isValid; } }
    public String Description { get { return _description; } }
    public String PropertyName { get { return _propertyName; } }
    public IEnumerable<RuleViolation> RuleViolations { get { return _ruleViolations; } }

    public ValidationResult(IEnumerable<RuleViolation> ruleViolations, String description, String propertyName)
    {
      Verify.NotNull(ruleViolations);
      Verify.False(String.IsNullOrEmpty(description));

      _isValid = ruleViolations.FirstOrDefault() == null;
      _ruleViolations = ruleViolations;
      _propertyName = propertyName;
      _description = description;
    }
  }
}
